<extend name="Base/category"/>
<block name="body">
  <div class="row">
    <div class="col-xs-12">
      <notempty name="keyword">
        <div class="page-header">
          <h3 style="font-size:16px;">共找到（<span class="text-danger">{$_total}</span>）件与“<span class="text-danger">{$keyword}</span>”相关的结果<!-- <small>（23）</small> --></h3>
        </div>
      </notempty>
      <ul class="breadcrumb search">
        <li><a href="{:U('Index/index')}">首页</a></li>
        <li><a href="{:U('Store/search',array('store_id'=>$store_id))}">全部分类</a></li>
        <notempty name="category">
          <foreach name="category" item="vo">
            <neq name="vo.cname" value="">
              <li><a href="{:U('Store/search', array('cid' => $vo['cid'],'store_id'=>$store_id))}" target="_self">{$vo['cname']}</a></li>
            </neq>
          </foreach>
        </notempty>
      </ul>
      <notempty name="category">
        <lt name="category.level" value="4">
          <div class="list-filter cate">
          
            <notempty name="searchArr">
            <dl class="dl-horizontal crumbAttr">
            
              <dt>已选：</dt>
                <dd class="abc">
                  <div class="clearfix" >
                  <volist name="searchArr" id="vo">
                     <span class="item item-on">
                        <switch name="vo.type">
                            <case value="brand"><a href="{:U('Item/search', array('cid' => $cid, 'prop'=>$prop, 'label' => $label, 'keyword' => $keyword, '_field' => $_field, '_order' => $_order,'item_label'=>$item_label))}"></case>
                            <case value="prop"> <a href="{:U('Item/search', array('cid' => $cid, 'brand'=>$brand, 'prop'=>$vo['param'], 'label' => $label, 'keyword' => $keyword, '_field' => $_field, '_order' => $_order,'item_label'=>$item_label))}"></case>
                        </switch>
                            {$vo['string']}<i class="icon icon-close"></i>
                        </a>
                     </span>
                  </volist>
                  </div>
                </dd>
            </dl>
            </notempty>
            
            <!--<php>if(empty($brand) && !empty($brandList)){</php>
            <dl class="dl-horizontal">

              <dt>品牌：</dt>
                <dd class="search_brand ">
                <!--规则：默认显示为当前看到这样。li获取部超过20个。点击更多时候，是单选，能看到showLogo_more，选择一个就把品牌这一栏收起了。点击更多。加载showLogo_more和showLogo_more_on  li中加li-sel&ndash;&gt;
                    <div class="brand_search_box"><i class="icon icon-search" style="font-size:14px;"></i>
                      <input type="text" class="J_search_brand">
                    </div>
                    <ul class="showLogo brand_limit J_search_list brand_list">
                    <volist name="brandList" id="vo">
                      <li class="">
                        <a href="{:U('search',array('brand'=>$vo['id'],'prop'=>$prop,'cid'=>$cid, 'label' => $label, 'keyword' => $keyword, '_field' => $_field, '_order' => $_order,'item_label'=>$item_label))}" brandid="{$vo['id']}" title="{$vo['name']}">
                             <img class="lazyImg" src="{:get_cover($vo['pic'], 'path')}" alt="{$vo['name']}"  >
                             {$vo['name']}
                        </a>
                        <i class="icon icon-close"></i>
                      </li>
                    </volist>
                    </ul>

                   <span class="butns J_brand_butns"><a href="javascript:;" class="submitBtn btn-positive">确定</a> <a href="javascript:;" class="cancelBtn">取消</a></span>
                   <span class="more">  <a href="javascript:;" class="brandmore">更多&nbsp;<i class="icon icon-arrow-bottom"></i></a></span>
                   <span class="more_on"> <a href="javascript:;" class="brandChoice" class="more_on"><i class="icon icon-add"></i>&nbsp;多选</a></span>
                </dd>
            </dl>
            <php>}</php>-->
            
            <dl class="dl-horizontal">
              <dt>分类：</dt>
              <foreach name="category" item="vo" key="k">
                <dd class="abc">
                  <div class="clearfix J_search_list"> <span class="item {$cate_active[$vo['pid']][0]}"><a href="{:U('Store/search', array('cid' => $vo['pid'], 'store_id' => $store_id, 'brand'=>$brand, 'prop'=>$prop, 'label' => $label, 'keyword' => $keyword, '_field' => $_field, '_order' => $_order))}">全部</a></span>
                    <foreach name="vo.item" item="val">
                        <span class="item {$cate_active[$vo['pid']][$val['id']]}">
                            <if condition="$k lt 2">
                                <a href="{:U('Store/search', array('cid' => $val['id'], 'store_id' => $store_id, 'brand'=>$brand, 'prop'=>$prop, 'label' => $label, 'keyword' => $keyword, '_field' => $_field, '_order' => $_order))}">{$val.name}</a>
                                <else />
                                <a href="{:U('Store/search', array('cid' => $val['id'], 'store_id' => $store_id, 'brand'=>$brand, 'prop'=>$prop, 'label' => $label, 'keyword' => $keyword, '_field' => $_field, '_order' => $_order,'item_label'=>$item_label))}">{$val.name}</a>
                            </if>
                        </span>
                    </foreach>
                  </div>
                  <span class="more">更多&nbsp;<i class="icon icon-arrow-bottom"></i></span> </dd>
              </foreach>
            </dl>

              <notempty name="itemLabel">
              <dl class="dl-horizontal">
                  <dt>标签：</dt>
                      <dd class="abc">
                          <div class="clearfix J_search_list">
                              <span class="item {$cate_active['item_label'][$vo['id']]}"><a href="{:U('Item/search', array('cid' => $cid, 'brand'=>$brand, 'prop'=>$prop, 'label' => $label, 'keyword' => $keyword, '_field' => $_field, '_order' => $_order))}">全部</a></span>
                          <foreach name="itemLabel" item="vo">
                              <span class="item {$cate_active['item_label'][$vo['id']]}"><a href="{:U('Item/search', array('cid' => $cid, 'brand'=>$brand, 'prop'=>$prop, 'label' => $label, 'keyword' => $keyword, '_field' => $_field, '_order' => $_order,'item_label'=>$vo['id']))}">{$vo.cname}</a></span>
                          </foreach>
                          </div>
                          <span class="more">更多&nbsp;<i class="icon icon-arrow-bottom"></i></span>
                      </dd>
              </dl>
              </notempty>
            
            <notempty name="item_property">
            <volist name="item_property" id="vo">
            <dl class="dl-horizontal">
              <dt>{$vo['cname']}：</dt>
                <dd class="abc">
                  <div class="clearfix J_search_list">
                  <volist name="vo.option" id="opt">
                     <span class="item"><a href="{:U('Store/search', array('cid' => $cid, 'brand'=>$brand, 'prop'=>$opt['opt_ids'], 'label' => $label, 'keyword' => $keyword, '_field' => $_field, '_order' => $_order,'item_label'=>$item_label))}">{$opt['option']}</a></span>
                  </volist>
                  </div>
                </dd>
            </dl>
            </volist>
            </notempty>
            
          </div>
          <script>
          seajs.use('jquery',function($){
              var prop = "{$prop}",
                  cid = "{$cid}",
                  label = "{$label}",
                  keyword = "{$keyword}",
                  _field = "{$_field}",
                  _order = "{$_order}";
                  
                $('.list-filter .J_search_list').each(function(index, element) {
                   // 品牌搜索
                   if($(element).hasClass('brand_list')){
                       if($(element).height()>194){
                           $(element).parent().children('.more').show();
                           
                           $(element).parent().children('.more').click(function(e) {
                              if($(element).parent().height()>223){
                                  $(element).parent().animate({'height':'223px'});
                              }else{
                                  $(element).removeClass('brand_limit');
                                  $(element).parent().animate({'height':($(element).height()+15)+'px'});
                                  
                              }
                          });
                       }
                      
                   // 分类、规格搜索
                   }else if($(element).height()>52){
                       $(element).parent().children('.more').show();
                       $(element).parent().children('.more').click(function(e) {
                          if($(element).parent().height()>50){
                              $(element).parent().animate({'height':'50px'});
                          }else{
                              $(element).parent().animate({'height':($(element).height()+15)+'px'});
                          }
                      });
                  }
              });
                
                // 品牌多选
                $('.more_on .brandChoice').on('click',function(){
                    $('.search_brand').addClass('showLogo_more');
                    $('.search_brand').find('ul').removeClass('brand_limit');
                    $('.J_brand_butns').show();
                });
                // 取消多选
                $('.cancelBtn').on('click',function(){
                    $('.search_brand').removeClass('showLogo_more');
                    $(this).parent().siblings('ul.J_search_list').find('li').removeClass('li-sel');
                    $('.J_brand_butns').hide();
                });
                // 品牌-多选确定
                var brandIds = '';
                $('.J_brand_butns .submitBtn').on('click',function(){
                    if($('.J_search_list .li-sel').length > 0){
                        $('.J_search_list .li-sel').each(function(key,obj){
                            brandIds += $(obj).find('a').attr('brandid')+',';
                        });
                        brandIds  = brandIds.replace(/(,*$)/g,'');
                        window.location.href = window.location.href+'?brand='+brandIds;
                    }
                    return false;
                });
                
                // 多选操作
                $('.list-filter').on('click','.showLogo_more .brand_list a',function(){
                    $(this).parent('li').addClass('li-sel');
                    return false;
                });
                
                $('.list-filter').on('click','.li-sel .icon-close',function(){
                    $(this).parent('li').removeClass('li-sel');
                    return false;
                });
                
                // 异步搜索品牌
                $('.brand_search_box .J_search_brand').on('keyup',function(){
                    var key = $.trim($(this).val());
                    if(key == ''){
                        return false;
                    }
                    
                    $.post("{:U('ajaxBrand')}",{key:key,prop:prop,cid:cid,label:label,keyword:keyword,_field:_field,_order:_order},function(rtn){
                        if(rtn.status){
                            $('.brand_list').html(rtn.html);
                        }else{
                            $.ui.error(rtn.info);
                        }
                    },'json');
                    return false;
                });
                
                
          })
          </script> 
        </lt>
      </notempty>
      
      <!-- 排序 -->
      <div class="list-filter sort">
        <dl class="dl-horizontal">
          <dd> <a href="{:U('Store/search', array('cid' => $cid, 'store_id' => $store_id, 'brand'=>$brand, 'prop'=>$prop, 'label' => $label, 'keyword' => $keyword, '_field' => 'is_top', '_order' => 'desc'))}" class="{$order_css['active']['is_top']['desc']}">推荐</a> <a href="{:U('Item/search', array('cid' => $cid, 'brand'=>$brand, 'prop'=>$prop, 'label' => $label, 'keyword' => $keyword, '_field' => 'viewnum', '_order' => 'desc'))}" class="{$order_css['active']['viewnum']['desc']}">人气</a> <a href="{:U('Item/search', array('cid' => $cid, 'brand'=>$brand, 'prop'=>$prop, 'label' => $label, 'keyword' => $keyword, '_field' => 'create_time', '_order' => 'desc'))}" class="{$order_css['active']['create_time']['desc']}">新品</a> <a href="{:U('Item/search', array('cid' => $cid, 'brand'=>$brand, 'prop'=>$prop, 'label' => $label, 'keyword' => $keyword, '_field' => 'buynum', '_order' => 'desc'))}" class="{$order_css['active']['buynum']['desc']}">销量</a> <a href="{:U('Item/search', array('cid' => $cid, 'brand'=>$brand, 'prop'=>$prop, 'label' => $label, 'keyword' => $keyword, '_field' => 'price', '_order' => 'desc'))}" class="{$order_css['active']['price']['desc']}">价格从高到低</a> <a href="{:U('Item/search', array('cid' => $cid, 'brand'=>$brand, 'prop'=>$prop, 'label' => $label, 'keyword' => $keyword, '_field' => 'price', '_order' => 'asc'))}" class="{$order_css['active']['price']['asc']}">价格从低到高</a> </dd>
        </dl>
      </div>
      
      <!-- 商品列表 -->
      <notempty name="lists">
        <div class="row item-list" id="J_load_items">
          <volist name="lists" id="vo">
            <div class="{$lists_item_default_style} item">
              <div class="thumbnail">
                <div style="position:relative;"> <a href="{:U('Item/detail', array('id' => $vo['id']))}" target="_blank"><img src="__IMG__/img-pai-bg.png" data-url="{:get_image_thumb($vo[cover_path], 400, 400)}" class="pic" alt="{$vo.name}"></a>
                  <div class="item_shop_info">
                     <a href="{:U('Store/index',array('store_id'=>$vo['store_id']))}" target="_blank" title="{:get_store_text($vo['store_id'])}" class="shop_name">{:get_store_text($vo['store_id'])}</a>
                     <a href="http://wpa.qq.com/msgrd?v=3&uin={:store_qq($vo['store_id'])}&site=qq&menu=yes" target="_blank" title="店铺名字"><i class="icon icon-qq"></i></a>
                  </div>
                </div>
                <div class="caption">
                  <h5 class="thumbnail-label"><a href="{:U('Item/detail', array('id' => $vo['id']))}"  title="{$vo.name}" alt="{$vo.name}" target="_blank"><!--{:get_short($vo['name'], 13)}-->{$vo['name']}</a></h5>
                  <div class="thumbnail-info">
                    <H3 class="text-danger">
                   
                    <em class="yen">&yen;</em>
                    <span class="mui-price-integer">{$vo.price}</span>
                      <if condition="C('IS_SHOW_BUYNUM')"><span href="{:U('Item/detail', array('id' => $vo['id']))}" class="btn btn-sm btn-default" target="_blank">已售： {$vo.buynum}件</span></if>
                    </H3>
                    <!--
                    --> 
                  </div>
                </div>
              </div>
            </div>
          </volist>
        </div>
        <script>
      seajs.use(['jquery','jquery.imglazyload'],function($,lz){
        var path=$('#J_load_items .item')
        var reloadWindow=function(){
            if($(window).width()>1600){
              path.removeClass('col-xs-3');
              path.addClass('col-xs-2');
            }else{
              path.removeClass('col-xs-2');
              path.addClass('col-xs-3');
            }
        }
        $(window).resize( function(){
            reloadWindow();
        });
        reloadWindow()
        $.imgLazyLoad({ diff: 100 })
          $(".form-inline").attr('action',"{:U('Store/search',array('store_id'=>$vo['store_id']))}");
      })
      </script>
        <div class="page"> {$_page} </div>
        <else/>
        <p class="list-empty">当前分类下暂无商品！<br>
          <a href="{:U('/')}" class="btn btn-positive">去看看别的&gt;</a></p>
      </notempty>
    </div>
  </div>
</block>
<block name="script"> {:hook('noticeMsg')} </block>
